//
//  MoBanTwalveViewController.m
//  MoBan
//
//  Created by apple on 16/7/28.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "MoBanTwalveViewController.h"

@interface MoBanTwalveViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,strong)UILabel *lable;

@property(nonatomic,strong)UIView *otherview;
@end

@implementation MoBanTwalveViewController
-(UIView *)otherview
{
    if (!_otherview) {
        _otherview = [[UIView alloc]initWithFrame:self.view.bounds];
        _otherview.backgroundColor = kcolor(0, 0, 0, 0.7);
        
    }
    return _otherview;
}
-(UILabel *)lable
{
    if (!_lable) {
        _lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KscrW, 40*Kscr)];
        _lable.text = @"搜索功能";
        _lable.textColor = [UIColor redColor];
    }
    return _lable;
}
-(UITableView *)tableview
{
    if (!_tableview) {
        _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KscrW, KscrH-KBar)];
        _tableview.backgroundColor = [UIColor clearColor];
        _tableview.dataSource =self;
        _tableview.delegate = self;
    }
    return _tableview;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.lable];
    [self.view addSubview:self.tableview];
    // Do any additional setup after loading the view.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    return cell;
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset NS_AVAILABLE_IOS(5_0);
{
    if (scrollView.contentOffset.y<-70) {
        
        [UIView animateWithDuration:0.3 animations:^{
//            self.tableview.contentInset =UIEdgeInsetsMake(KscrH, 0, 0, 0);
            self.tableview.top = KscrH;

        } completion:^(BOOL finished) {
            self.tableview.top=0;
            [self.view addSubview:self.otherview];
            
        }];
    }
    
    
    NSLog(@"%f",scrollView.contentOffset.y);
}
@end
